home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
An Invitation to the Roland World of Music
/
Roland - An Invitation To The Roland World Of Music.bin
/
vb
/
vb30
/
disk1
/
number.fr_
/
number.bin
Wrap
Text File
|
1993-04-27
|
3KB
|
104 lines
VERSION 2.00
Begin Form frmNumber
Caption = "Number System"
ClientHeight = 3390
ClientLeft = 2160
ClientTop = 1950
ClientWidth = 4515
Height = 3795
Left = 2100
LinkTopic = "Form5"
ScaleHeight = 3390
ScaleWidth = 4515
Top = 1605
Width = 4635
Begin CommandButton cmdClose
Caption = "&Close"
Height = 495
Left = 2760
TabIndex = 4
Top = 1920
Width = 1215
End
Begin OptionButton optHexButton
Caption = "Use &hexadecimal"
Height = 495
Left = 600
TabIndex = 3
Top = 2520
Width = 1815
End
Begin OptionButton optDecButton
Caption = "Use &decimal"
Height = 495
Left = 600
TabIndex = 2
Top = 1920
Value = -1 'True
Width = 1815
End
Begin OptionButton optOctButton
Caption = "Use &octal"
Height = 495
Left = 600
TabIndex = 1
Top = 1320
Width = 1815
End
Begin TextBox txtNumber
Height = 375
Left = 600
TabIndex = 0
Top = 600
Width = 3375
End
Begin Label Label1
Caption = "Enter a number:"
Height = 255
Left = 600
TabIndex = 5
Top = 240
Width = 2175
End
End
Option Explicit
Dim CurrentNum As Variant
Sub cmdClose_Click ()
Unload Me ' Unload this form.
End Sub
Sub optDecButton_Click ()
txtNumber.Text = Format(CurrentNum)
End Sub
Sub optHexButton_Click ()
txtNumber.Text = Hex(CurrentNum)
End Sub
Sub optOctButton_Click ()
txtNumber.Text = Oct(CurrentNum)
End Sub
Sub txtNumber_Change ()
' Val function interprets numbers beginning with &O as octal;
' numbers beginning with &H as hexidecimal.
If optOctButton.Value = True Then
CurrentNum = Val("&O" & LTrim(txtNumber.Text) & "&")
ElseIf optDecButton.Value = True Then
CurrentNum = Val(LTrim(txtNumber.Text) & "&")
Else
CurrentNum = Val("&H" & LTrim(txtNumber.Text) & "&")
End If
End Sub
Sub txtNumber_KeyPress (KeyAscii As Integer)
' This code prevents the user from entering
' a negative number, or a decimal point.
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
Beep
End If
End Sub